using UnityEngine;

public class SceneGame_HUD : MonoBehaviour
{
	
	public Texture2D Pointer;
	
	public float HealthDisplayWidth;
	public float Speed;
	public float Length;
	public float Amplitude;
	public float Angle;
	private float _Current;
	
	public void Start()
	{
		_Current = -Pointer.width;
	}
	
	public void Update()
	{
		float smoothDeltaTime = Mathf.Clamp(Time.smoothDeltaTime, 0.01666667f, float.MaxValue);
		
		float min = -Pointer.width;
		float max = Screen.width;
		
		_Current = Mathf.Clamp(_Current + Speed * smoothDeltaTime, min, max);
		if (_Current >= max)
			_Current = min;
	}
	
	public void OnGUI()
	{
		Vector2 pos = new Vector2(
			_Current,
			Amplitude * Mathf.Sin(_Current / Screen.width * Angle)
		);
		GUI.DrawTexture(
			new Rect(
				pos.x,
				pos.y + 360,
				Pointer.width,
				Pointer.height
			),
			Pointer
		);
	}
	
}